1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.Builder;
26 
27 private import glib.ConstructionException;
28 private import glib.ErrorG;
29 private import glib.GException;
30 private import glib.ListSG;
31 private import glib.MemorySlice;
32 private import glib.Str;
33 private import glib.c.functions;
34 private import gobject.Closure;
35 private import gobject.ObjectG;
36 private import gobject.ParamSpec;
37 private import gobject.Value;
38 private import gtk.BuilderScopeIF;
39 private import gtk.c.functions;
40 public  import gtk.c.types;
41 
42 
43 /**
44  * A `GtkBuilder` reads XML descriptions of a user interface and
45  * instantiates the described objects.
46  * 
47  * To create a `GtkBuilder` from a user interface description, call
48  * [ctor@Gtk.Builder.new_from_file], [ctor@Gtk.Builder.new_from_resource]
49  * or [ctor@Gtk.Builder.new_from_string].
50  * 
51  * In the (unusual) case that you want to add user interface
52  * descriptions from multiple sources to the same `GtkBuilder` you can
53  * call [ctor@Gtk.Builder.new] to get an empty builder and populate it by
54  * (multiple) calls to [method@Gtk.Builder.add_from_file],
55  * [method@Gtk.Builder.add_from_resource] or
56  * [method@Gtk.Builder.add_from_string].
57  * 
58  * A `GtkBuilder` holds a reference to all objects that it has constructed
59  * and drops these references when it is finalized. This finalization can
60  * cause the destruction of non-widget objects or widgets which are not
61  * contained in a toplevel window. For toplevel windows constructed by a
62  * builder, it is the responsibility of the user to call
63  * [method@Gtk.Window.destroy] to get rid of them and all the widgets
64  * they contain.
65  * 
66  * The functions [method@Gtk.Builder.get_object] and
67  * [method@Gtk.Builder.get_objects] can be used to access the widgets in
68  * the interface by the names assigned to them inside the UI description.
69  * Toplevel windows returned by these functions will stay around until the
70  * user explicitly destroys them with [method@Gtk.Window.destroy]. Other
71  * widgets will either be part of a larger hierarchy constructed by the
72  * builder (in which case you should not have to worry about their lifecycle),
73  * or without a parent, in which case they have to be added to some container
74  * to make use of them. Non-widget objects need to be reffed with
75  * g_object_ref() to keep them beyond the lifespan of the builder.
76  * 
77  * # GtkBuilder UI Definitions
78  * 
79  * `GtkBuilder` parses textual descriptions of user interfaces which are
80  * specified in XML format. We refer to these descriptions as “GtkBuilder
81  * UI definitions” or just “UI definitions” if the context is clear.
82  * 
83  * The toplevel element is `<interface>`. It optionally takes a “domain”
84  * attribute, which will make the builder look for translated strings
85  * using `dgettext()` in the domain specified. This can also be done by
86  * calling [method@Gtk.Builder.set_translation_domain] on the builder.
87  * 
88  * Objects are described by `<object>` elements, which can contain
89  * `<property>` elements to set properties, `<signal>` elements which
90  * connect signals to handlers, and `<child>` elements, which describe
91  * child objects (most often widgets inside a container, but also e.g.
92  * actions in an action group, or columns in a tree model). A `<child>`
93  * element contains an `<object>` element which describes the child object.
94  * 
95  * The target toolkit version(s) are described by `<requires>` elements,
96  * the “lib” attribute specifies the widget library in question (currently
97  * the only supported value is “gtk”) and the “version” attribute specifies
98  * the target version in the form “`<major>`.`<minor>`”. `GtkBuilder` will
99  * error out if the version requirements are not met.
100  * 
101  * Typically, the specific kind of object represented by an `<object>`
102  * element is specified by the “class” attribute. If the type has not
103  * been loaded yet, GTK tries to find the `get_type()` function from the
104  * class name by applying heuristics. This works in most cases, but if
105  * necessary, it is possible to specify the name of the `get_type()`
106  * function explicitly with the "type-func" attribute.
107  * 
108  * Objects may be given a name with the “id” attribute, which allows the
109  * application to retrieve them from the builder with
110  * [method@Gtk.Builder.get_object]. An id is also necessary to use the
111  * object as property value in other parts of the UI definition. GTK
112  * reserves ids starting and ending with `___` (three consecutive
113  * underscores) for its own purposes.
114  * 
115  * Setting properties of objects is pretty straightforward with the
116  * `<property>` element: the “name” attribute specifies the name of the
117  * property, and the content of the element specifies the value.
118  * If the “translatable” attribute is set to a true value, GTK uses
119  * `gettext()` (or `dgettext()` if the builder has a translation domain set)
120  * to find a translation for the value. This happens before the value
121  * is parsed, so it can be used for properties of any type, but it is
122  * probably most useful for string properties. It is also possible to
123  * specify a context to disambiguate short strings, and comments which
124  * may help the translators.
125  * 
126  * `GtkBuilder` can parse textual representations for the most common
127  * property types: characters, strings, integers, floating-point numbers,
128  * booleans (strings like “TRUE”, “t”, “yes”, “y”, “1” are interpreted
129  * as %TRUE, strings like “FALSE”, “f”, “no”, “n”, “0” are interpreted
130  * as %FALSE), enumerations (can be specified by their name, nick or
131  * integer value), flags (can be specified by their name, nick, integer
132  * value, optionally combined with “|”, e.g.
133  * “GTK_INPUT_HINT_EMOJI|GTK_INPUT_HINT_LOWERCASE”)
134  * and colors (in a format understood by [method@Gdk.RGBA.parse]).
135  * 
136  * `GVariant`s can be specified in the format understood by
137  * g_variant_parse(), and pixbufs can be specified as a filename of an
138  * image file to load.
139  * 
140  * Objects can be referred to by their name and by default refer to
141  * objects declared in the local XML fragment and objects exposed via
142  * [method@Gtk.Builder.expose_object]. In general, `GtkBuilder` allows
143  * forward references to objects — declared in the local XML; an object
144  * doesn’t have to be constructed before it can be referred to. The
145  * exception to this rule is that an object has to be constructed before
146  * it can be used as the value of a construct-only property.
147  * 
148  * It is also possible to bind a property value to another object's
149  * property value using the attributes "bind-source" to specify the
150  * source object of the binding, and optionally, "bind-property" and
151  * "bind-flags" to specify the source property and source binding flags
152  * respectively. Internally, `GtkBuilder` implements this using `GBinding`
153  * objects. For more information see g_object_bind_property().
154  * 
155  * Sometimes it is necessary to refer to widgets which have implicitly
156  * been constructed by GTK as part of a composite widget, to set
157  * properties on them or to add further children (e.g. the content area
158  * of a `GtkDialog`). This can be achieved by setting the “internal-child”
159  * property of the `<child>` element to a true value. Note that `GtkBuilder`
160  * still requires an `<object>` element for the internal child, even if it
161  * has already been constructed.
162  * 
163  * A number of widgets have different places where a child can be added
164  * (e.g. tabs vs. page content in notebooks). This can be reflected in
165  * a UI definition by specifying the “type” attribute on a `<child>`
166  * The possible values for the “type” attribute are described in the
167  * sections describing the widget-specific portions of UI definitions.
168  * 
169  * # Signal handlers and function pointers
170  * 
171  * Signal handlers are set up with the `<signal>` element. The “name”
172  * attribute specifies the name of the signal, and the “handler” attribute
173  * specifies the function to connect to the signal.
174  * The remaining attributes, “after”, “swapped” and “object”, have the
175  * same meaning as the corresponding parameters of the
176  * g_signal_connect_object() or g_signal_connect_data() functions. A
177  * “last_modification_time” attribute is also allowed, but it does not
178  * have a meaning to the builder.
179  * 
180  * If you rely on `GModule` support to lookup callbacks in the symbol table,
181  * the following details should be noted:
182  * 
183  * When compiling applications for Windows, you must declare signal callbacks
184  * with %G_MODULE_EXPORT, or they will not be put in the symbol table.
185  * On Linux and Unix, this is not necessary; applications should instead
186  * be compiled with the -Wl,--export-dynamic `CFLAGS`, and linked against
187  * `gmodule-export-2.0`.
188  * 
189  * # A GtkBuilder UI Definition
190  * 
191  * ```xml
192  * <interface>
193  * <object class="GtkDialog" id="dialog1">
194  * <child internal-child="content_area">
195  * <object class="GtkBox" id="vbox1">
196  * <child internal-child="action_area">
197  * <object class="GtkBox" id="hbuttonbox1">
198  * <child>
199  * <object class="GtkButton" id="ok_button">
200  * <property name="label" translatable="yes">_Ok</property>
201  * <property name="use-underline">True</property>
202  * <signal name="clicked" handler="ok_button_clicked"/>
203  * </object>
204  * </child>
205  * </object>
206  * </child>
207  * </object>
208  * </child>
209  * </object>
210  * </interface>
211  * ```
212  * 
213  * Beyond this general structure, several object classes define their
214  * own XML DTD fragments for filling in the ANY placeholders in the DTD
215  * above. Note that a custom element in a <child> element gets parsed by
216  * the custom tag handler of the parent object, while a custom element in
217  * an <object> element gets parsed by the custom tag handler of the object.
218  * 
219  * These XML fragments are explained in the documentation of the
220  * respective objects.
221  * 
222  * A `<template>` tag can be used to define a widget class’s components.
223  * See the [GtkWidget documentation](class.Widget.html#building-composite-widgets-from-template-xml) for details.
224  */
225 public class Builder : ObjectG
226 {
227 	/** the main Gtk struct */
228 	protected GtkBuilder* gtkBuilder;
229 
230 	/** Get the main Gtk struct */
231 	public GtkBuilder* getBuilderStruct(bool transferOwnership = false)
232 	{
233 		if (transferOwnership)
234 			ownedRef = false;
235 		return gtkBuilder;
236 	}
237 
238 	/** the main Gtk struct as a void* */
239 	protected override void* getStruct()
240 	{
241 		return cast(void*)gtkBuilder;
242 	}
243 
244 	/**
245 	 * Sets our main struct and passes it to the parent class.
246 	 */
247 	public this (GtkBuilder* gtkBuilder, bool ownedRef = false)
248 	{
249 		this.gtkBuilder = gtkBuilder;
250 		super(cast(GObject*)gtkBuilder, ownedRef);
251 	}
252 
253 	/**
254 	 * Gets all objects that have been constructed by @builder. Note that
255 	 * this function does not increment the reference counts of the returned
256 	 * objects.
257 	 *
258 	 * Returns: a newly-allocated #GSList containing all the objects
259 	 *     constructed by the #GtkBuilder instance. It should be freed by
260 	 *     g_slist_free()
261 	 */
262 	public ObjectG[] getObjects()
263 	{
264 		auto __p = gtk_builder_get_objects(gtkBuilder);
265 
266 		if(__p is null)
267 		{
268 			return null;
269 		}
270 
271 		return new ListSG(cast(GSList*) __p).toArray!ObjectG();
272 	}
273 
274 	/**
275 	 */
276 
277 	/** */
278 	public static GType getType()
279 	{
280 		return gtk_builder_get_type();
281 	}
282 
283 	/**
284 	 * Creates a new empty builder object.
285 	 *
286 	 * This function is only useful if you intend to make multiple calls
287 	 * to [method@Gtk.Builder.add_from_file], [method@Gtk.Builder.add_from_resource]
288 	 * or [method@Gtk.Builder.add_from_string] in order to merge multiple UI
289 	 * descriptions into a single builder.
290 	 *
291 	 * Returns: a new (empty) `GtkBuilder` object
292 	 *
293 	 * Throws: ConstructionException GTK+ fails to create the object.
294 	 */
295 	public this()
296 	{
297 		auto __p = gtk_builder_new();
298 
299 		if(__p is null)
300 		{
301 			throw new ConstructionException("null returned by new");
302 		}
303 
304 		this(cast(GtkBuilder*) __p, true);
305 	}
306 
307 	/**
308 	 * Parses the UI definition in the file @filename.
309 	 *
310 	 * If there is an error opening the file or parsing the description then
311 	 * the program will be aborted. You should only ever attempt to parse
312 	 * user interface descriptions that are shipped as part of your program.
313 	 *
314 	 * Params:
315 	 *     filename = filename of user interface description file
316 	 *
317 	 * Returns: a `GtkBuilder` containing the described interface
318 	 *
319 	 * Throws: ConstructionException GTK+ fails to create the object.
320 	 */
321 	public this(string filename)
322 	{
323 		auto __p = gtk_builder_new_from_file(Str.toStringz(filename));
324 
325 		if(__p is null)
326 		{
327 			throw new ConstructionException("null returned by new_from_file");
328 		}
329 
330 		this(cast(GtkBuilder*) __p, true);
331 	}
332 
333 	/**
334 	 * Parses a file containing a UI definition and merges it with
335 	 * the current contents of @builder.
336 	 *
337 	 * This function is useful if you need to call
338 	 * [method@Gtk.Builder.set_current_object]) to add user data to
339 	 * callbacks before loading GtkBuilder UI. Otherwise, you probably
340 	 * want [ctor@Gtk.Builder.new_from_file] instead.
341 	 *
342 	 * If an error occurs, 0 will be returned and @error will be assigned a
343 	 * `GError` from the `GTK_BUILDER_ERROR`, `G_MARKUP_ERROR` or `G_FILE_ERROR`
344 	 * domains.
345 	 *
346 	 * It’s not really reasonable to attempt to handle failures of this
347 	 * call. You should not use this function with untrusted files (ie:
348 	 * files that are not part of your application). Broken `GtkBuilder`
349 	 * files can easily crash your program, and it’s possible that memory
350 	 * was leaked leading up to the reported failure. The only reasonable
351 	 * thing to do when an error is detected is to call `g_error()`.
352 	 *
353 	 * Params:
354 	 *     filename = the name of the file to parse
355 	 *
356 	 * Returns: %TRUE on success, %FALSE if an error occurred
357 	 *
358 	 * Throws: GException on failure.
359 	 */
360 	public bool addFromFile(string filename)
361 	{
362 		GError* err = null;
363 
364 		auto __p = gtk_builder_add_from_file(gtkBuilder, Str.toStringz(filename), &err) != 0;
365 
366 		if (err !is null)
367 		{
368 			throw new GException( new ErrorG(err) );
369 		}
370 
371 		return __p;
372 	}
373 
374 	/**
375 	 * Parses a resource file containing a UI definition
376 	 * and merges it with the current contents of @builder.
377 	 *
378 	 * This function is useful if you need to call
379 	 * [method@Gtk.Builder.set_current_object] to add user data to
380 	 * callbacks before loading GtkBuilder UI. Otherwise, you probably
381 	 * want [ctor@Gtk.Builder.new_from_resource] instead.
382 	 *
383 	 * If an error occurs, 0 will be returned and @error will be assigned a
384 	 * `GError` from the %GTK_BUILDER_ERROR, %G_MARKUP_ERROR or %G_RESOURCE_ERROR
385 	 * domain.
386 	 *
387 	 * It’s not really reasonable to attempt to handle failures of this
388 	 * call.  The only reasonable thing to do when an error is detected is
389 	 * to call g_error().
390 	 *
391 	 * Params:
392 	 *     resourcePath = the path of the resource file to parse
393 	 *
394 	 * Returns: %TRUE on success, %FALSE if an error occurred
395 	 *
396 	 * Throws: GException on failure.
397 	 */
398 	public bool addFromResource(string resourcePath)
399 	{
400 		GError* err = null;
401 
402 		auto __p = gtk_builder_add_from_resource(gtkBuilder, Str.toStringz(resourcePath), &err) != 0;
403 
404 		if (err !is null)
405 		{
406 			throw new GException( new ErrorG(err) );
407 		}
408 
409 		return __p;
410 	}
411 
412 	/**
413 	 * Parses a string containing a UI definition and merges it
414 	 * with the current contents of @builder.
415 	 *
416 	 * This function is useful if you need to call
417 	 * [method@Gtk.Builder.set_current_object] to add user data to
418 	 * callbacks before loading `GtkBuilder` UI. Otherwise, you probably
419 	 * want [ctor@Gtk.Builder.new_from_string] instead.
420 	 *
421 	 * Upon errors %FALSE will be returned and @error will be assigned a
422 	 * `GError` from the %GTK_BUILDER_ERROR, %G_MARKUP_ERROR or
423 	 * %G_VARIANT_PARSE_ERROR domain.
424 	 *
425 	 * It’s not really reasonable to attempt to handle failures of this
426 	 * call.  The only reasonable thing to do when an error is detected is
427 	 * to call g_error().
428 	 *
429 	 * Params:
430 	 *     buffer = the string to parse
431 	 *     length = the length of @buffer (may be -1 if @buffer is nul-terminated)
432 	 *
433 	 * Returns: %TRUE on success, %FALSE if an error occurred
434 	 *
435 	 * Throws: GException on failure.
436 	 */
437 	public bool addFromString(string buffer, ptrdiff_t length)
438 	{
439 		GError* err = null;
440 
441 		auto __p = gtk_builder_add_from_string(gtkBuilder, Str.toStringz(buffer), length, &err) != 0;
442 
443 		if (err !is null)
444 		{
445 			throw new GException( new ErrorG(err) );
446 		}
447 
448 		return __p;
449 	}
450 
451 	/**
452 	 * Parses a file containing a UI definition building only the
453 	 * requested objects and merges them with the current contents
454 	 * of @builder.
455 	 *
456 	 * Upon errors, 0 will be returned and @error will be assigned a
457 	 * `GError` from the %GTK_BUILDER_ERROR, %G_MARKUP_ERROR or %G_FILE_ERROR
458 	 * domain.
459 	 *
460 	 * If you are adding an object that depends on an object that is not
461 	 * its child (for instance a `GtkTreeView` that depends on its
462 	 * `GtkTreeModel`), you have to explicitly list all of them in @object_ids.
463 	 *
464 	 * Params:
465 	 *     filename = the name of the file to parse
466 	 *     objectIds = nul-terminated array of objects to build
467 	 *
468 	 * Returns: %TRUE on success, %FALSE if an error occurred
469 	 *
470 	 * Throws: GException on failure.
471 	 */
472 	public bool addObjectsFromFile(string filename, string[] objectIds)
473 	{
474 		GError* err = null;
475 
476 		auto __p = gtk_builder_add_objects_from_file(gtkBuilder, Str.toStringz(filename), Str.toStringzArray(objectIds), &err) != 0;
477 
478 		if (err !is null)
479 		{
480 			throw new GException( new ErrorG(err) );
481 		}
482 
483 		return __p;
484 	}
485 
486 	/**
487 	 * Parses a resource file containing a UI definition, building
488 	 * only the requested objects and merges them with the current
489 	 * contents of @builder.
490 	 *
491 	 * Upon errors, 0 will be returned and @error will be assigned a
492 	 * `GError` from the %GTK_BUILDER_ERROR, %G_MARKUP_ERROR or %G_RESOURCE_ERROR
493 	 * domain.
494 	 *
495 	 * If you are adding an object that depends on an object that is not
496 	 * its child (for instance a `GtkTreeView` that depends on its
497 	 * `GtkTreeModel`), you have to explicitly list all of them in @object_ids.
498 	 *
499 	 * Params:
500 	 *     resourcePath = the path of the resource file to parse
501 	 *     objectIds = nul-terminated array of objects to build
502 	 *
503 	 * Returns: %TRUE on success, %FALSE if an error occurred
504 	 *
505 	 * Throws: GException on failure.
506 	 */
507 	public bool addObjectsFromResource(string resourcePath, string[] objectIds)
508 	{
509 		GError* err = null;
510 
511 		auto __p = gtk_builder_add_objects_from_resource(gtkBuilder, Str.toStringz(resourcePath), Str.toStringzArray(objectIds), &err) != 0;
512 
513 		if (err !is null)
514 		{
515 			throw new GException( new ErrorG(err) );
516 		}
517 
518 		return __p;
519 	}
520 
521 	/**
522 	 * Parses a string containing a UI definition, building only the
523 	 * requested objects and merges them with the current contents of
524 	 * @builder.
525 	 *
526 	 * Upon errors %FALSE will be returned and @error will be assigned a
527 	 * `GError` from the %GTK_BUILDER_ERROR or %G_MARKUP_ERROR domain.
528 	 *
529 	 * If you are adding an object that depends on an object that is not
530 	 * its child (for instance a `GtkTreeView` that depends on its
531 	 * `GtkTreeModel`), you have to explicitly list all of them in @object_ids.
532 	 *
533 	 * Params:
534 	 *     buffer = the string to parse
535 	 *     length = the length of @buffer (may be -1 if @buffer is nul-terminated)
536 	 *     objectIds = nul-terminated array of objects to build
537 	 *
538 	 * Returns: %TRUE on success, %FALSE if an error occurred
539 	 *
540 	 * Throws: GException on failure.
541 	 */
542 	public bool addObjectsFromString(string buffer, ptrdiff_t length, string[] objectIds)
543 	{
544 		GError* err = null;
545 
546 		auto __p = gtk_builder_add_objects_from_string(gtkBuilder, Str.toStringz(buffer), length, Str.toStringzArray(objectIds), &err) != 0;
547 
548 		if (err !is null)
549 		{
550 			throw new GException( new ErrorG(err) );
551 		}
552 
553 		return __p;
554 	}
555 
556 	/**
557 	 * Creates a closure to invoke the function called @function_name.
558 	 *
559 	 * This is using the create_closure() implementation of @builder's
560 	 * [iface@Gtk.BuilderScope].
561 	 *
562 	 * If no closure could be created, %NULL will be returned and @error
563 	 * will be set.
564 	 *
565 	 * Params:
566 	 *     functionName = name of the function to look up
567 	 *     flags = closure creation flags
568 	 *     object = Object to create the closure with
569 	 *
570 	 * Returns: A new closure for invoking @function_name
571 	 *
572 	 * Throws: GException on failure.
573 	 */
574 	public Closure createClosure(string functionName, GtkBuilderClosureFlags flags, ObjectG object)
575 	{
576 		GError* err = null;
577 
578 		auto __p = gtk_builder_create_closure(gtkBuilder, Str.toStringz(functionName), flags, (object is null) ? null : object.getObjectGStruct(), &err);
579 
580 		if (err !is null)
581 		{
582 			throw new GException( new ErrorG(err) );
583 		}
584 
585 		if(__p is null)
586 		{
587 			return null;
588 		}
589 
590 		return ObjectG.getDObject!(Closure)(cast(GClosure*) __p, true);
591 	}
592 
593 	/**
594 	 * Add @object to the @builder object pool so it can be
595 	 * referenced just like any other object built by builder.
596 	 *
597 	 * Params:
598 	 *     name = the name of the object exposed to the builder
599 	 *     object = the object to expose
600 	 */
601 	public void exposeObject(string name, ObjectG object)
602 	{
603 		gtk_builder_expose_object(gtkBuilder, Str.toStringz(name), (object is null) ? null : object.getObjectGStruct());
604 	}
605 
606 	/**
607 	 * Main private entry point for building composite components
608 	 * from template XML.
609 	 *
610 	 * This is exported purely to let `gtk-builder-tool` validate
611 	 * templates, applications have no need to call this function.
612 	 *
613 	 * Params:
614 	 *     object = the object that is being extended
615 	 *     templateType = the type that the template is for
616 	 *     buffer = the string to parse
617 	 *     length = the length of @buffer (may be -1 if @buffer is nul-terminated)
618 	 *
619 	 * Returns: A positive value on success, 0 if an error occurred
620 	 *
621 	 * Throws: GException on failure.
622 	 */
623 	public bool extendWithTemplate(ObjectG object, GType templateType, string buffer, ptrdiff_t length)
624 	{
625 		GError* err = null;
626 
627 		auto __p = gtk_builder_extend_with_template(gtkBuilder, (object is null) ? null : object.getObjectGStruct(), templateType, Str.toStringz(buffer), length, &err) != 0;
628 
629 		if (err !is null)
630 		{
631 			throw new GException( new ErrorG(err) );
632 		}
633 
634 		return __p;
635 	}
636 
637 	/**
638 	 * Gets the current object set via gtk_builder_set_current_object().
639 	 *
640 	 * Returns: the current object
641 	 */
642 	public ObjectG getCurrentObject()
643 	{
644 		auto __p = gtk_builder_get_current_object(gtkBuilder);
645 
646 		if(__p is null)
647 		{
648 			return null;
649 		}
650 
651 		return ObjectG.getDObject!(ObjectG)(cast(GObject*) __p);
652 	}
653 
654 	/**
655 	 * Gets the object named @name.
656 	 *
657 	 * Note that this function does not increment the reference count
658 	 * of the returned object.
659 	 *
660 	 * Params:
661 	 *     name = name of object to get
662 	 *
663 	 * Returns: the object named @name
664 	 */
665 	public ObjectG getObject(string name)
666 	{
667 		auto __p = gtk_builder_get_object(gtkBuilder, Str.toStringz(name));
668 
669 		if(__p is null)
670 		{
671 			return null;
672 		}
673 
674 		return ObjectG.getDObject!(ObjectG)(cast(GObject*) __p);
675 	}
676 
677 	/**
678 	 * Gets the scope in use that was set via gtk_builder_set_scope().
679 	 *
680 	 * Returns: the current scope
681 	 */
682 	public BuilderScopeIF getScope()
683 	{
684 		auto __p = gtk_builder_get_scope(gtkBuilder);
685 
686 		if(__p is null)
687 		{
688 			return null;
689 		}
690 
691 		return ObjectG.getDObject!(BuilderScopeIF)(cast(GtkBuilderScope*) __p);
692 	}
693 
694 	/**
695 	 * Gets the translation domain of @builder.
696 	 *
697 	 * Returns: the translation domain
698 	 */
699 	public string getTranslationDomain()
700 	{
701 		return Str.toString(gtk_builder_get_translation_domain(gtkBuilder));
702 	}
703 
704 	/**
705 	 * Looks up a type by name.
706 	 *
707 	 * This is using the virtual function that `GtkBuilder` has
708 	 * for that purpose. This is mainly used when implementing
709 	 * the `GtkBuildable` interface on a type.
710 	 *
711 	 * Params:
712 	 *     typeName = type name to lookup
713 	 *
714 	 * Returns: the `GType` found for @type_name or %G_TYPE_INVALID
715 	 *     if no type was found
716 	 */
717 	public GType getTypeFromName(string typeName)
718 	{
719 		return gtk_builder_get_type_from_name(gtkBuilder, Str.toStringz(typeName));
720 	}
721 
722 	/**
723 	 * Sets the current object for the @builder.
724 	 *
725 	 * The current object can be thought of as the `this` object that the
726 	 * builder is working for and will often be used as the default object
727 	 * when an object is optional.
728 	 *
729 	 * [method@Gtk.Widget.init_template] for example will set the current
730 	 * object to the widget the template is inited for. For functions like
731 	 * [ctor@Gtk.Builder.new_from_resource], the current object will be %NULL.
732 	 *
733 	 * Params:
734 	 *     currentObject = the new current object
735 	 */
736 	public void setCurrentObject(ObjectG currentObject)
737 	{
738 		gtk_builder_set_current_object(gtkBuilder, (currentObject is null) ? null : currentObject.getObjectGStruct());
739 	}
740 
741 	/**
742 	 * Sets the scope the builder should operate in.
743 	 *
744 	 * If @scope is %NULL, a new [class@Gtk.BuilderCScope] will be created.
745 	 *
746 	 * Params:
747 	 *     scope_ = the scope to use
748 	 */
749 	public void setScope(BuilderScopeIF scope_)
750 	{
751 		gtk_builder_set_scope(gtkBuilder, (scope_ is null) ? null : scope_.getBuilderScopeStruct());
752 	}
753 
754 	/**
755 	 * Sets the translation domain of @builder.
756 	 *
757 	 * Params:
758 	 *     domain = the translation domain
759 	 */
760 	public void setTranslationDomain(string domain)
761 	{
762 		gtk_builder_set_translation_domain(gtkBuilder, Str.toStringz(domain));
763 	}
764 
765 	/**
766 	 * Demarshals a value from a string.
767 	 *
768 	 * This function calls g_value_init() on the @value argument,
769 	 * so it need not be initialised beforehand.
770 	 *
771 	 * Can handle char, uchar, boolean, int, uint, long,
772 	 * ulong, enum, flags, float, double, string, `GdkRGBA` and
773 	 * `GtkAdjustment` type values.
774 	 *
775 	 * Upon errors %FALSE will be returned and @error will be
776 	 * assigned a `GError` from the %GTK_BUILDER_ERROR domain.
777 	 *
778 	 * Params:
779 	 *     pspec = the `GParamSpec` for the property
780 	 *     string_ = the string representation of the value
781 	 *     value = the `GValue` to store the result in
782 	 *
783 	 * Returns: %TRUE on success
784 	 *
785 	 * Throws: GException on failure.
786 	 */
787 	public bool valueFromString(ParamSpec pspec, string string_, out Value value)
788 	{
789 		GValue* outvalue = sliceNew!GValue();
790 		GError* err = null;
791 
792 		auto __p = gtk_builder_value_from_string(gtkBuilder, (pspec is null) ? null : pspec.getParamSpecStruct(), Str.toStringz(string_), outvalue, &err) != 0;
793 
794 		if (err !is null)
795 		{
796 			throw new GException( new ErrorG(err) );
797 		}
798 
799 		value = ObjectG.getDObject!(Value)(outvalue, true);
800 
801 		return __p;
802 	}
803 
804 	/**
805 	 * Demarshals a value from a string.
806 	 *
807 	 * Unlike [method@Gtk.Builder.value_from_string], this function
808 	 * takes a `GType` instead of `GParamSpec`.
809 	 *
810 	 * Calls g_value_init() on the @value argument, so it
811 	 * need not be initialised beforehand.
812 	 *
813 	 * Upon errors %FALSE will be returned and @error will be
814 	 * assigned a `GError` from the %GTK_BUILDER_ERROR domain.
815 	 *
816 	 * Params:
817 	 *     type = the `GType` of the value
818 	 *     string_ = the string representation of the value
819 	 *     value = the `GValue` to store the result in
820 	 *
821 	 * Returns: %TRUE on success
822 	 *
823 	 * Throws: GException on failure.
824 	 */
825 	public bool valueFromStringType(GType type, string string_, out Value value)
826 	{
827 		GValue* outvalue = sliceNew!GValue();
828 		GError* err = null;
829 
830 		auto __p = gtk_builder_value_from_string_type(gtkBuilder, type, Str.toStringz(string_), outvalue, &err) != 0;
831 
832 		if (err !is null)
833 		{
834 			throw new GException( new ErrorG(err) );
835 		}
836 
837 		value = ObjectG.getDObject!(Value)(outvalue, true);
838 
839 		return __p;
840 	}
841 }